﻿<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>首页</title>
        <%@ include file="/pages/common/common_f.jsp" %>
        <link rel="stylesheet" type="text/css" href="${ctx}/css/index_pub.css">
		<link rel="stylesheet" type="text/css" href="${ctx}/css/index.css">
		<script type="text/javascript" src="${ctx}/js/ImageScroll.js"></script>
		<script type="text/javascript">
			$(document).ready(function(){	
				
				$('#loginbutt').click(login)
				
				//回车键触发登录
				$("body").keydown(function(event){
					if(event.keyCode==13)
						login();
				});
				
				loadHotRoute();//加载热门线路
				loadNews();//加载新闻
				loadPics();//加载图片
				loadComp();//加载公司简介
				loadContact();//加载联系方式
				
				if('${param.login}'){
					alert('请先登录后才能查看线路预定线路');
				}
					
			});
		
			 /** 登录 */
			function login(){
				var r = $('#loginForm').form('validate');
				if(!r) {
					return false;
				}
				var url="${ctx}/user/login.usr";
				var param = "userName="+$('#userName').val();
				param += "&userPwd="+$('#userPwd').val();
				param += "&vcode="+$('#vcode').val();
				$.post(url,param,function(data){
					if(data.success){//操作成功
						$('#showname').html($('#userName').val());
						$('.page_wite').show('slow');
						$('#users_rig').hide('slow');
						$('#topmenu').append('<a id="uc" href="${ctx}/userCenter/queryUser.usr" class="easyui-linkbutton menua" plain="true">用户中心</a>');
					}else{
						$.messager.alert('提示',data.msg,'warning');	
					}
				});
			}
			 /** 注销 */
			 function logout(){
				$.post('${ctx}/user/ajaxlogout.usr',function(data){
					if(data.success){
						$('.page_wite').hide('slow');
						$('#users_rig').show('slow');
						if($('#uc'))
							$('#uc').remove();
					}
				})	 
			 }
			 
			function getVcode(){
				var url="${ctx}/vcode/getVcode.usr?time="+new Date().getTime();
				$("#codeImg").attr("src",url);	
			}
			function register(){
				window.open("${ctx}/pages/front/register.jsp");
			}
			
			/** 加载热门线路 */
			function loadHotRoute(){
				$.post('${ctx}/index/getHoteRoute.usr',function(data){
					if(data.success){
						var htmls=[];
						$.each(data.routes,function(i,e){
							var price='￥'+e.lowestPrice1+'起';
							if(e.lowestPrice1==0)
								price='暂无价格';
							if(i%2==0)
								htmls.push('<li class="oddli"><a href="${ctx}/route/queryRoute.usr?routeId='+e.routeId+'&type=${type}"  target="_blank">'+e.routeName+'</a><span>'+price+'</span></li>');
							else
								htmls.push('<li><a href="${ctx}/route/queryRoute.usr?routeId='+e.routeId+'&type=${type}"  target="_blank">'+e.routeName+'</a><span>'+price+'</span></li>');
						});
						$("#routeList").html(htmls.join(''));
					}else{
						alert(data.msg);
					}
				});
			}
			
			/** 加载新闻 */
			function loadNews(){
				$.post('${ctx}/index/getNews.usr',function(data){
					if(data.success){
						var htmls=[];
						$.each(data.news,function(i,e){
							if(i%2==0)
								htmls.push('<li class="oddli"><a href="${ctx}/frontNews/getNewsById.usr?newsId='+e.newsId+'" target="_blank">'+(i+1)+'、'+e.newsTitle+'</a></li>');
							else
								htmls.push('<li><a href="${ctx}/frontNews/getNewsById.usr?newsId='+e.newsId+'" target="_blank">'+(i+1)+'、'+e.newsTitle+'</a></li>');
						});
						$("#newsList").html(htmls.join(''));
					}else{
						alert(data.msg);
					}
				});
				
			}
			
			/** 加载公司简介 */
			function loadComp(){
				$.post('${ctx}/index/getComp.usr',function(data){
					if(data.success){
						$("#comp").html(data.comp);
					}else{
						alert(data.msg);
					}
				});
			}
			
			/** 加载联系方式 */
			function loadContact(){
				$.post('${ctx}/index/getContact.usr',function(data){
					if(data.success){
						$("#contact").html(data.contact);
					}else{
						alert(data.msg);
					}
				});
			}
			
			/** 加载图片 */
			function loadPics(){
				$.post('${ctx}/index/getPics.usr',function(data){
					if(data.success){
						var htmls=[];
						$.each(data.pics,function(i,e){
							htmls.push('<a><img src="${ctx}/upload/'+e.pictureUrl+'" alt="'+e.pictureName+'" /></a>');
						});
						$("#scroll").html(htmls.join(''));
						$("#scroll").ImageScroll({delay:3000, maskBgColor:"#000"});//图片轮换	
					}else{
						alert(data.msg);
					}
				});
			}
		</script>
		
    </head>
    <body>
        <div class="page_all" >
           
			
            <jsp:include page="/pages/front/inc/header.jsp"></jsp:include><!-- 顶部导航 -->
            <div class="page_wite" style='<c:if test="${empty userVo}">display: none;</c:if>'>
            	<img src="${ctx}/img/front/weti_bg.gif" width=34px height=34px />
				<span>欢迎您：&nbsp;&nbsp;</span> 
				<p><a id="showname" href="#">${userVo.userInfo.userName}</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a id="outTo" href="javascript:void(0);" onclick="logout();">退出</a></p>
            </div>
			
            <div class="page_cont">
            	<div class="page_cont_left">
					<div id="users_rig" class="users_rig" style='<c:if test="${empty userVo}">display: block;</c:if>'>
						<div class="users_tit">
            			用户登录
            			</div>
            			<div>
            				<table>
            					<tr>
            						<td width="50px;">用户名:</td>
            						<td><input id="userName"  type="text" style="width: 110px;" /></td>
            					</tr>
            					<tr>
            						<td>密&nbsp;&nbsp;码:</td>
            						<td><input id="userPwd" type="password" style="width: 110px;" /></td>
            					</tr>
            					<tr>
            						<td>验证码:</td>
            						<td><input id="vcode" style="width: 40px;">
                  &nbsp; <img id="codeImg" src="${ctx}/vcode/getVcode.usr?time="+new Date().getTime()" align="top" style="border:1px solid #ccc;cursor: pointer;" onclick="getVcode();"></td>
            					</tr>
            				</table>
            			</div>
						<div class="res_b"></div> 
						<p class="user_butt">
							<input id="loginbutt" type="button" value="登 录"/>&nbsp;
							<input id="loginbutt" type="button" value="注 册" onclick="register();"/>
						</p>       			
            		</div>
					
					<div class="rec_line">
						<div class="users_tit">
            				推荐线路
            			</div>
						<div class="line_cont">
							<ul class="line_list" id="routeList">
								<div class="loading">正在加载</div>
								
							</ul>
							<h2 class="line_foot"><a href="${ctx}/route/queryMoreRoute.usr" target="_blank">更多>></a></h2>
						</div>
					</div>
					
					<div class="contact">
						<div class="users_tit">
            				联系方式
            			</div>
						<div id="contact"></div>
					</div>
					<div class="contact">
						<div class="users_tit">
            				在线QQ咨询
            			</div>
						<p>
							<a href="http://wpa.qq.com/msgrd?V=1&Uin=1981243155&Site=www.rrf.com.cn &Menu=no" target="_blank" style="text-decoration: none;">
							<img height="29" border="0" width="29" alt="在线QQ咨询" title="在线QQ咨询" src="${ctx}/img/front/qq_online.png">在线QQ咨询
							</a>
							<br>						
							<a href="http://wpa.qq.com/msgrd?V=1&Uin=1158007197&Site=www.rrf.com.cn &Menu=no" target="_blank" style="text-decoration: none;">
							<img height="29" border="0" width="29" alt="在线QQ咨询" title="在线QQ咨询" src="${ctx}/img/front/qq_online.png">在线QQ咨询
							</a>
						</p>						
					</div>
					
            	</div>
			
				<div class="page_cont_right">
            		<div class="first_cont">						
						<div id="scroll"> 
							<div class="loading">正在加载</div>  
						</div>
						<div class="dongtai">
							<div class="users_tit">
            				新闻咨询
            				</div>
							<div class="line_cont">
								<ul class="line_list" id="newsList">
									<div class="loading">正在加载</div>	
								</ul>
								<h2 class="line_foot"><a href="${ctx}/frontNews/queryNews.usr" target="_blank">更多>></a></h2>
							</div>
						</div>					
					</div>
					<div class="greap">&nbsp;</div>
					<div class="second_cont">
						<div class="users_tit">
            				公司简介
            			</div>
						<div class="comp_cont">
							<img style="float: left; margin-right: 28px;" alt="Comsenz" src="http://www.comsenz.com/templates/default/images/company/company.jpg">
							<div id="comp"></div>
						</div>
					</div>
					
            	</div>
            	<div style="clear: both;"></div>
            </div>
            </div>
        </div>
    </body>
</html>
